﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Shoozla.DataModel.Helper;
using Shoozla.DataModel;


namespace Shoozla.View
{
    /// <summary>
    /// Interaction logic for SearchAddinView.xaml
    /// </summary>
    public partial class SearchAddinView : Window
    {

        public SearchAddinView(Window owner)
        {
            InitializeComponent();
            Owner = owner;
            searcherLogoIM.Source = ImageHelper.ImageToBitmapImage(App.CoverSearcher.GetIcon());
            addInCB.Items.Clear();
            addinDescLB.Visibility = System.Windows.Visibility.Hidden;

            foreach (CoverSearcher cs in App.AvailableCoverSearchers)
                addInCB.Items.Add(cs);

            addInCB.SelectedIndex = 0;
        }

        public SearchAddinView(Window owner, int count) : this(owner)
        {       
            summaryLB.Content = "Selected songs: " + count;
        }

        private void continueBT_Click(object sender, RoutedEventArgs e)
        {
            DialogResult = true;
        }

        private void cancelBT_Click(object sender, RoutedEventArgs e)
        {
            DialogResult = false;
        }

        private void addInCB_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
           CoverSearcher cs = e.AddedItems[0] as CoverSearcher;
           if (cs != null)
           {
               addinDescLB.Content = cs.AddInDescription;
               addinDescLB.Visibility = System.Windows.Visibility.Visible;
               searcherLogoIM.Source = ImageHelper.ImageToBitmapImage(cs.GetIcon());
               App.CoverSearcher = cs;
           }
        }
    }
}
